var ns, toast;
app = new Vue({
    el: '#app',
    data: {
        list: [],
        activeNames: [],
        ProjectID: 0,
        MeterType: 1,
        IDs: [],
    },
    methods: {
        formattTime(time, type) {
            return ns.DateFormatChinese(time, type);
        },
        get_data() {
            var that = this;
            that.list = [];
            var options = {};
            options.action = "getchargemeterlog";
            options.ProjectID = that.ProjectID;
            // options.WriteDate = that.form.startMonth;
            options.IDs = that.IDs;
            options.Type = that.MeterType;
            // console.log(JSON.stringify(options));
            toast.loading({
                title: "加载中",
                duration: 2000
            }, function (ret) { });
            ns.post(options, function (succeed, data, err) {
                toast.hide();
                if (succeed) {
                    that.list = data.data;
                } else if (err) {
                    api.toast({
                        msg: err,
                        duration: 3000,
                        location: 'bottom'
                    });
                }
            });
        },
        onClickEdit(item) {
            var that = this;
            var chooseList = [];
            chooseList.push(item);
            ns.openWin('meterwriteread_more', '抄表读数', {
                startMonth: item.WriteDate,
                chooseList: chooseList,
                IsEdit: true,
                MeterType: that.MeterType,
            });
        },
    }
});
apiready = function () {
    api.parseTapmode();
    ns = window.Foresight.Util;
    app.ProjectID = api.pageParam.ProjectID || 0;
    app.MeterType = api.pageParam.MeterReadType || 1;//表类型
    app.IDs = api.pageParam.IDs;
    toast = new auiToast();

    app.get_data();

    api.addEventListener({
        name: 'reload_chhoose_read'
    }, function (ret) {
        app.get_data();
    })
};
